import axios from '@/libs/axios1.js';
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' };

// 创建空白工程
export const creatBlankPro = (id, data, mode) => {
    return axios({
        url: `/topo-edit/project/import/async?templateId=${id}&mode=${mode}`,
        method: 'post',
        data: JSON.stringify(data),
        headers: jsonHeaders,
    });
};

// 根据工程id查询状态
export const queryProjectstatus = (projectId) => {
    return axios({
        url: `/topo-edit/project/${projectId}`,
        method: 'get',
        headers: jsonHeaders,
    });
};

// 部署工程
export const deployProject = (id) => {
    return axios({
        url: `/topo-edit/projects/${id}/deploy/async`,
        method: 'post',
        headers: jsonHeaders,
    });
};
// 获取部署进度
export const getDeployProgress = (deployId) => {
    return axios({
        url: `/topo-edit/deploy/${deployId}/record`,
        method: 'get',
        headers: jsonHeaders,
    });
};
// 查询工程部署详情
export const getProjectDeployDetail = (deployId, params) => {
    return axios({
        url: `/deploy/deploying/${deployId}/detail`,
        method: 'get',
        params: params,
        headers: jsonHeaders,
    });
};

// 获取接入机器的接入路径
export const geturl = (params) => {
    return axios({
        url: `/netns/access/${params.vmId}/${params.type}`,
        method: 'post',
        data: params.data,
        headers: jsonHeaders,
    });
};
//查询子网络列表
export const queryNetworkList = (projectId, networkId) => {
    return axios({
        url: `/topo-edit/topo/projects/${projectId}/networks/${networkId}/load_topology`,
        method: 'get',
        headers: jsonHeaders,
    });
};

export const clearDeloyPro = (id, data) => {
    return axios({
        url: `/topo-edit/project/clear/${id}`,
        method: 'post',
        data: JSON.stringify(data),
        headers: jsonHeaders,
    });
};

//获取虚拟机列表
export const getVms = (params) => {
    return axios({
        url: `/topo-edit/deployed/vms`,
        method: 'get',
        params: params,
        headers: jsonHeaders,
    });
};

//详情
export const hostDetail = (deviceId) => {
    return axios({
      url: `/topo-edit/deployed/vms/${deviceId}`,
      method: 'get',
      headers: jsonHeaders
    });
  };
//获取场景
export const getTestList = (projectId) => {
    return axios({
        url: `/process/tests`,
        method: 'get',
        params: {
            pageIndex: 1,
            pageSize: 1,
            enabled: true,
            projectId,
        },
        headers: jsonHeaders,
    });
};
